Repository navigation
fix(terminal): closing a tab is never a silent no-op - #27132
Conversation
Clicking x did nothing when the worktree catalog had not hydrated yet or the tab's group record was missing. The close now routes by the host the tab's own PTY ids (or unified tab) name, and with no host at all still prunes locally and reaches main's close record; per-PTY teardown already fails closed for an unproven host. closeUnifiedTab closes a tab whose group record is gone instead of returning null. Fixes #11308
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The changed close paths have no established issue requiring a fix before merge. Pre-merge checks |
|
ELI5
Sometimes clicking × on a terminal tab did nothing. The app didn't yet know which machine the tab belonged to, so it gave up without a word. Now the close always happens: it asks the tab itself which machine it runs on, and if nothing knows, it still closes the tab here.
What Changed
closeTerminalTabresolved the tab's host from the worktree catalog. Before the catalog hydrated, after a failed worktree scan, or with an ambiguous legacy runtime, there was no route, so it calledonCanceland returned. The tab-strip × passes noonCancel, so the click looked lost.closeUnifiedTabreturnednullwhen the tab's group record was missing, so no close path could remove that tab.remote:<env>@@<handle>id names its paired server), and otherwise from the host recorded on its unified tab.wasLastTabis then computed from the worktree's remaining tabs.resolveTerminalCloseRoute(state, worktreeId, tabId)insrc/renderer/src/lib/terminal-close-route.ts. It reusesgetPtyExecutionHostand the retirement plan's PTY-id collector (now exported), so no new PTY-id parsing is added.tabs-close-actions.ts, every group read is optional and the order falls back to the worktree's tabs.Why
buildTerminalTabRetirementPlanuses the strict teardown owner), so a local prune never kills another host's process.Linked Issue
Fixes #11308
Also covers the routing half of #11800 and #17767. Those stay open for their host-side parts.
Visual Proof
N/A: the change is that a click which did nothing now closes the tab. This is covered by unit tests on the exact states from the issue.
Testing
New
terminal-tab-actions-unrouted-close.test.ts:remote:env-1@@hPTY, the host close is sent toenv-1;New
tabs-close-dangling-group.test.ts: terminal and editor tabs with a missing group are removed, andwasLastTabis correct.All five new tests fail on
origin/main.Renderer terminal, tabs-slice, retirement and route suites pass (5579 tests).
pnpm tc, oxlint, andpnpm run check:code-quality:changedpass.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Renderer only, no wire change. SSH: an
ssh:PTY id routes to the local/SSH path exactly as a resolved SSH worktree does. Folder workspaces: the catalog route and the unified-tab host cover folder keys. Windows: no paths involved.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)